﻿#region Using directives

using System;
using System.Data;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;

using NetROS.Tiers.Entities;
using NetROS.Tiers.Data;

#endregion

namespace NetROS.Tiers.Data.Bases
{	
	///<summary>
	/// This class is the base class for any <see cref="ObracunKamataProknjizenProviderBase"/> implementation.
	/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
	///</summary>
	public abstract partial class ObracunKamataProknjizenProviderBaseCore : EntityProviderBase<NetROS.Tiers.Entities.ObracunKamataProknjizen, NetROS.Tiers.Entities.ObracunKamataProknjizenKey>
	{		
		#region Get from Many To Many Relationship Functions
		#endregion	
		
		#region Delete Methods

		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="transactionManager">A <see cref="TransactionManager"/> object.</param>
		/// <param name="key">The unique identifier of the row to delete.</param>
		/// <returns>Returns true if operation suceeded.</returns>
		public override bool Delete(TransactionManager transactionManager, NetROS.Tiers.Entities.ObracunKamataProknjizenKey key)
		{
			return Delete(transactionManager, key.IDKnjizenjeStavka);
		}
		
		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="iDKnjizenjeStavka">. Primary Key.</param>
		/// <remarks>Deletes based on primary key(s).</remarks>
		/// <returns>Returns true if operation suceeded.</returns>
		public bool Delete(System.Int32 iDKnjizenjeStavka)
		{
			return Delete(null, iDKnjizenjeStavka);
		}
		
		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="iDKnjizenjeStavka">. Primary Key.</param>
		/// <remarks>Deletes based on primary key(s).</remarks>
		/// <returns>Returns true if operation suceeded.</returns>
		public abstract bool Delete(TransactionManager transactionManager, System.Int32 iDKnjizenjeStavka);		
		
		#endregion Delete Methods
		
		#region Get By Foreign Key Functions
	
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_tblObracunKamataProknjizen_tblObracunKamata key.
		///		FK_tblObracunKamataProknjizen_tblObracunKamata Description: 
		/// </summary>
		/// <param name="iDObracunKamata"></param>
		/// <returns>Returns a typed collection of NetROS.Tiers.Entities.ObracunKamataProknjizen objects.</returns>
		public NetROS.Tiers.Entities.TList<ObracunKamataProknjizen> GetByIDObracunKamata(System.Int32 iDObracunKamata)
		{
			int count = -1;
			return GetByIDObracunKamata(iDObracunKamata, 0,int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_tblObracunKamataProknjizen_tblObracunKamata key.
		///		FK_tblObracunKamataProknjizen_tblObracunKamata Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="iDObracunKamata"></param>
		/// <returns>Returns a typed collection of NetROS.Tiers.Entities.ObracunKamataProknjizen objects.</returns>
		/// <remarks></remarks>
		public NetROS.Tiers.Entities.TList<ObracunKamataProknjizen> GetByIDObracunKamata(TransactionManager transactionManager, System.Int32 iDObracunKamata)
		{
			int count = -1;
			return GetByIDObracunKamata(transactionManager, iDObracunKamata, 0, int.MaxValue, out count);
		}
		
			/// <summary>
		/// 	Gets rows from the datasource based on the FK_tblObracunKamataProknjizen_tblObracunKamata key.
		///		FK_tblObracunKamataProknjizen_tblObracunKamata Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="iDObracunKamata"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of NetROS.Tiers.Entities.ObracunKamataProknjizen objects.</returns>
		public NetROS.Tiers.Entities.TList<ObracunKamataProknjizen> GetByIDObracunKamata(TransactionManager transactionManager, System.Int32 iDObracunKamata, int start, int pageLength)
		{
			int count = -1;
			return GetByIDObracunKamata(transactionManager, iDObracunKamata, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_tblObracunKamataProknjizen_tblObracunKamata key.
		///		fK_tblObracunKamataProknjizen_tblObracunKamata Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="iDObracunKamata"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of NetROS.Tiers.Entities.ObracunKamataProknjizen objects.</returns>
		public NetROS.Tiers.Entities.TList<ObracunKamataProknjizen> GetByIDObracunKamata(System.Int32 iDObracunKamata, int start, int pageLength)
		{
			int count =  -1;
			return GetByIDObracunKamata(null, iDObracunKamata, start, pageLength,out count);	
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_tblObracunKamataProknjizen_tblObracunKamata key.
		///		fK_tblObracunKamataProknjizen_tblObracunKamata Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="iDObracunKamata"></param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of NetROS.Tiers.Entities.ObracunKamataProknjizen objects.</returns>
		public NetROS.Tiers.Entities.TList<ObracunKamataProknjizen> GetByIDObracunKamata(System.Int32 iDObracunKamata, int start, int pageLength,out int count)
		{
			return GetByIDObracunKamata(null, iDObracunKamata, start, pageLength, out count);	
		}
						
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_tblObracunKamataProknjizen_tblObracunKamata key.
		///		FK_tblObracunKamataProknjizen_tblObracunKamata Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="iDObracunKamata"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns a typed collection of NetROS.Tiers.Entities.ObracunKamataProknjizen objects.</returns>
		public abstract NetROS.Tiers.Entities.TList<ObracunKamataProknjizen> GetByIDObracunKamata(TransactionManager transactionManager, System.Int32 iDObracunKamata, int start, int pageLength, out int count);
		
	
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_tblObracunKamataProknjizen_tblOrganizacija key.
		///		FK_tblObracunKamataProknjizen_tblOrganizacija Description: 
		/// </summary>
		/// <param name="iDOrganizacija"></param>
		/// <returns>Returns a typed collection of NetROS.Tiers.Entities.ObracunKamataProknjizen objects.</returns>
		public NetROS.Tiers.Entities.TList<ObracunKamataProknjizen> GetByIDOrganizacija(System.Int32 iDOrganizacija)
		{
			int count = -1;
			return GetByIDOrganizacija(iDOrganizacija, 0,int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_tblObracunKamataProknjizen_tblOrganizacija key.
		///		FK_tblObracunKamataProknjizen_tblOrganizacija Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="iDOrganizacija"></param>
		/// <returns>Returns a typed collection of NetROS.Tiers.Entities.ObracunKamataProknjizen objects.</returns>
		/// <remarks></remarks>
		public NetROS.Tiers.Entities.TList<ObracunKamataProknjizen> GetByIDOrganizacija(TransactionManager transactionManager, System.Int32 iDOrganizacija)
		{
			int count = -1;
			return GetByIDOrganizacija(transactionManager, iDOrganizacija, 0, int.MaxValue, out count);
		}
		
			/// <summary>
		/// 	Gets rows from the datasource based on the FK_tblObracunKamataProknjizen_tblOrganizacija key.
		///		FK_tblObracunKamataProknjizen_tblOrganizacija Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="iDOrganizacija"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of NetROS.Tiers.Entities.ObracunKamataProknjizen objects.</returns>
		public NetROS.Tiers.Entities.TList<ObracunKamataProknjizen> GetByIDOrganizacija(TransactionManager transactionManager, System.Int32 iDOrganizacija, int start, int pageLength)
		{
			int count = -1;
			return GetByIDOrganizacija(transactionManager, iDOrganizacija, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_tblObracunKamataProknjizen_tblOrganizacija key.
		///		fK_tblObracunKamataProknjizen_tblOrganizacija Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="iDOrganizacija"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of NetROS.Tiers.Entities.ObracunKamataProknjizen objects.</returns>
		public NetROS.Tiers.Entities.TList<ObracunKamataProknjizen> GetByIDOrganizacija(System.Int32 iDOrganizacija, int start, int pageLength)
		{
			int count =  -1;
			return GetByIDOrganizacija(null, iDOrganizacija, start, pageLength,out count);	
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_tblObracunKamataProknjizen_tblOrganizacija key.
		///		fK_tblObracunKamataProknjizen_tblOrganizacija Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="iDOrganizacija"></param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of NetROS.Tiers.Entities.ObracunKamataProknjizen objects.</returns>
		public NetROS.Tiers.Entities.TList<ObracunKamataProknjizen> GetByIDOrganizacija(System.Int32 iDOrganizacija, int start, int pageLength,out int count)
		{
			return GetByIDOrganizacija(null, iDOrganizacija, start, pageLength, out count);	
		}
						
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_tblObracunKamataProknjizen_tblOrganizacija key.
		///		FK_tblObracunKamataProknjizen_tblOrganizacija Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="iDOrganizacija"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns a typed collection of NetROS.Tiers.Entities.ObracunKamataProknjizen objects.</returns>
		public abstract NetROS.Tiers.Entities.TList<ObracunKamataProknjizen> GetByIDOrganizacija(TransactionManager transactionManager, System.Int32 iDOrganizacija, int start, int pageLength, out int count);
		
		#endregion

		#region Get By Index Functions
		
		/// <summary>
		/// 	Gets a row from the DataSource based on its primary key.
		/// </summary>
		/// <param name="transactionManager">A <see cref="TransactionManager"/> object.</param>
		/// <param name="key">The unique identifier of the row to retrieve.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <returns>Returns an instance of the Entity class.</returns>
		public override NetROS.Tiers.Entities.ObracunKamataProknjizen Get(TransactionManager transactionManager, NetROS.Tiers.Entities.ObracunKamataProknjizenKey key, int start, int pageLength)
		{
			return GetByIDKnjizenjeStavka(transactionManager, key.IDKnjizenjeStavka, start, pageLength);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the primary key PK_tblObracunKamataProknjizen index.
		/// </summary>
		/// <param name="iDKnjizenjeStavka"></param>
		/// <returns>Returns an instance of the <see cref="NetROS.Tiers.Entities.ObracunKamataProknjizen"/> class.</returns>
		public NetROS.Tiers.Entities.ObracunKamataProknjizen GetByIDKnjizenjeStavka(System.Int32 iDKnjizenjeStavka)
		{
			int count = -1;
			return GetByIDKnjizenjeStavka(null,iDKnjizenjeStavka, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_tblObracunKamataProknjizen index.
		/// </summary>
		/// <param name="iDKnjizenjeStavka"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="NetROS.Tiers.Entities.ObracunKamataProknjizen"/> class.</returns>
		public NetROS.Tiers.Entities.ObracunKamataProknjizen GetByIDKnjizenjeStavka(System.Int32 iDKnjizenjeStavka, int start, int pageLength)
		{
			int count = -1;
			return GetByIDKnjizenjeStavka(null, iDKnjizenjeStavka, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_tblObracunKamataProknjizen index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="iDKnjizenjeStavka"></param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="NetROS.Tiers.Entities.ObracunKamataProknjizen"/> class.</returns>
		public NetROS.Tiers.Entities.ObracunKamataProknjizen GetByIDKnjizenjeStavka(TransactionManager transactionManager, System.Int32 iDKnjizenjeStavka)
		{
			int count = -1;
			return GetByIDKnjizenjeStavka(transactionManager, iDKnjizenjeStavka, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_tblObracunKamataProknjizen index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="iDKnjizenjeStavka"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="NetROS.Tiers.Entities.ObracunKamataProknjizen"/> class.</returns>
		public NetROS.Tiers.Entities.ObracunKamataProknjizen GetByIDKnjizenjeStavka(TransactionManager transactionManager, System.Int32 iDKnjizenjeStavka, int start, int pageLength)
		{
			int count = -1;
			return GetByIDKnjizenjeStavka(transactionManager, iDKnjizenjeStavka, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_tblObracunKamataProknjizen index.
		/// </summary>
		/// <param name="iDKnjizenjeStavka"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="NetROS.Tiers.Entities.ObracunKamataProknjizen"/> class.</returns>
		public NetROS.Tiers.Entities.ObracunKamataProknjizen GetByIDKnjizenjeStavka(System.Int32 iDKnjizenjeStavka, int start, int pageLength, out int count)
		{
			return GetByIDKnjizenjeStavka(null, iDKnjizenjeStavka, start, pageLength, out count);
		}
		
				
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_tblObracunKamataProknjizen index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="iDKnjizenjeStavka"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns an instance of the <see cref="NetROS.Tiers.Entities.ObracunKamataProknjizen"/> class.</returns>
		public abstract NetROS.Tiers.Entities.ObracunKamataProknjizen GetByIDKnjizenjeStavka(TransactionManager transactionManager, System.Int32 iDKnjizenjeStavka, int start, int pageLength, out int count);
						
		/// <summary>
		/// 	Gets rows from the datasource based on the primary key UIX_IDObracunKamata_KontoSifra_Kontrola index.
		/// </summary>
		/// <param name="iDObracunKamata"></param>
		/// <param name="kontoSifraPrijenos"></param>
		/// <param name="kontrola"></param>
		/// <returns>Returns an instance of the <see cref="NetROS.Tiers.Entities.ObracunKamataProknjizen"/> class.</returns>
		public NetROS.Tiers.Entities.ObracunKamataProknjizen GetByIDObracunKamataKontoSifraPrijenosKontrola(System.Int32 iDObracunKamata, System.String kontoSifraPrijenos, System.String kontrola)
		{
			int count = -1;
			return GetByIDObracunKamataKontoSifraPrijenosKontrola(null,iDObracunKamata, kontoSifraPrijenos, kontrola, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the UIX_IDObracunKamata_KontoSifra_Kontrola index.
		/// </summary>
		/// <param name="iDObracunKamata"></param>
		/// <param name="kontoSifraPrijenos"></param>
		/// <param name="kontrola"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="NetROS.Tiers.Entities.ObracunKamataProknjizen"/> class.</returns>
		public NetROS.Tiers.Entities.ObracunKamataProknjizen GetByIDObracunKamataKontoSifraPrijenosKontrola(System.Int32 iDObracunKamata, System.String kontoSifraPrijenos, System.String kontrola, int start, int pageLength)
		{
			int count = -1;
			return GetByIDObracunKamataKontoSifraPrijenosKontrola(null, iDObracunKamata, kontoSifraPrijenos, kontrola, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the UIX_IDObracunKamata_KontoSifra_Kontrola index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="iDObracunKamata"></param>
		/// <param name="kontoSifraPrijenos"></param>
		/// <param name="kontrola"></param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="NetROS.Tiers.Entities.ObracunKamataProknjizen"/> class.</returns>
		public NetROS.Tiers.Entities.ObracunKamataProknjizen GetByIDObracunKamataKontoSifraPrijenosKontrola(TransactionManager transactionManager, System.Int32 iDObracunKamata, System.String kontoSifraPrijenos, System.String kontrola)
		{
			int count = -1;
			return GetByIDObracunKamataKontoSifraPrijenosKontrola(transactionManager, iDObracunKamata, kontoSifraPrijenos, kontrola, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the UIX_IDObracunKamata_KontoSifra_Kontrola index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="iDObracunKamata"></param>
		/// <param name="kontoSifraPrijenos"></param>
		/// <param name="kontrola"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="NetROS.Tiers.Entities.ObracunKamataProknjizen"/> class.</returns>
		public NetROS.Tiers.Entities.ObracunKamataProknjizen GetByIDObracunKamataKontoSifraPrijenosKontrola(TransactionManager transactionManager, System.Int32 iDObracunKamata, System.String kontoSifraPrijenos, System.String kontrola, int start, int pageLength)
		{
			int count = -1;
			return GetByIDObracunKamataKontoSifraPrijenosKontrola(transactionManager, iDObracunKamata, kontoSifraPrijenos, kontrola, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the UIX_IDObracunKamata_KontoSifra_Kontrola index.
		/// </summary>
		/// <param name="iDObracunKamata"></param>
		/// <param name="kontoSifraPrijenos"></param>
		/// <param name="kontrola"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="NetROS.Tiers.Entities.ObracunKamataProknjizen"/> class.</returns>
		public NetROS.Tiers.Entities.ObracunKamataProknjizen GetByIDObracunKamataKontoSifraPrijenosKontrola(System.Int32 iDObracunKamata, System.String kontoSifraPrijenos, System.String kontrola, int start, int pageLength, out int count)
		{
			return GetByIDObracunKamataKontoSifraPrijenosKontrola(null, iDObracunKamata, kontoSifraPrijenos, kontrola, start, pageLength, out count);
		}
		
				
		/// <summary>
		/// 	Gets rows from the datasource based on the UIX_IDObracunKamata_KontoSifra_Kontrola index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="iDObracunKamata"></param>
		/// <param name="kontoSifraPrijenos"></param>
		/// <param name="kontrola"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns an instance of the <see cref="NetROS.Tiers.Entities.ObracunKamataProknjizen"/> class.</returns>
		public abstract NetROS.Tiers.Entities.ObracunKamataProknjizen GetByIDObracunKamataKontoSifraPrijenosKontrola(TransactionManager transactionManager, System.Int32 iDObracunKamata, System.String kontoSifraPrijenos, System.String kontrola, int start, int pageLength, out int count);
						
		#endregion "Get By Index Functions"
	
		#region Custom Methods
		
		
		#endregion

		#region Helper Functions	
		
		/// <summary>
		/// Fill a NetROS.Tiers.Entities.TList&lt;ObracunKamataProknjizen&gt; From a DataReader.
		/// </summary>
		/// <param name="reader">Datareader</param>
		/// <param name="rows">The collection to fill</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">number of rows.</param>
		/// <returns>a <see cref="NetROS.Tiers.Entities.TList&lt;ObracunKamataProknjizen&gt;"/></returns>
		public static NetROS.Tiers.Entities.TList<ObracunKamataProknjizen> Fill(IDataReader reader, NetROS.Tiers.Entities.TList<ObracunKamataProknjizen> rows, int start, int pageLength)
		{
		// advance to the starting row
		for (int i = 0; i < start; i++)
		{
			if (!reader.Read())
			return rows; // not enough rows, just return
		}
		for (int i = 0; i < pageLength; i++)
		{
			if (!reader.Read())
			break; // we are done
			string key = null;
			
			NetROS.Tiers.Entities.ObracunKamataProknjizen c = null;
			if (DataRepository.Provider.UseEntityFactory)
			{
			key = new System.Text.StringBuilder("ObracunKamataProknjizen")
			.Append("|").Append((reader.IsDBNull(((int)NetROS.Tiers.Entities.ObracunKamataProknjizenColumn.IDKnjizenjeStavka - 1))?(int)0:(System.Int32)reader[((int)NetROS.Tiers.Entities.ObracunKamataProknjizenColumn.IDKnjizenjeStavka - 1)]).ToString()).ToString();
			c = EntityManager.LocateOrCreate<ObracunKamataProknjizen>(
			key.ToString(), // EntityTrackingKey
			"ObracunKamataProknjizen",  //Creational Type
			DataRepository.Provider.EntityCreationalFactoryType,  //Factory used to create entity
			DataRepository.Provider.EnableEntityTracking); // Track this entity?
			}
			else
			{
			c = new NetROS.Tiers.Entities.ObracunKamataProknjizen();
			}
			
			if (!DataRepository.Provider.EnableEntityTracking ||
			c.EntityState == EntityState.Added ||
			(DataRepository.Provider.EnableEntityTracking &&
			((DataRepository.Provider.CurrentLoadPolicy == LoadPolicy.PreserveChanges && c.EntityState == EntityState.Unchanged) ||
			(DataRepository.Provider.CurrentLoadPolicy == LoadPolicy.DiscardChanges && (c.EntityState == EntityState.Unchanged ||
								c.EntityState == EntityState.Changed)))))
						{
			c.SuppressEntityEvents = true;
			c.IDKnjizenjeStavka = (System.Int32)reader["IDKnjizenjeStavka"];
			c.OriginalIDKnjizenjeStavka = c.IDKnjizenjeStavka;
			c.IDOrganizacija = (System.Int32)reader["IDOrganizacija"];
			c.IDObracunKamata = (System.Int32)reader["IDObracunKamata"];
			c.KontoSifraPrijenos = (System.String)reader["KontoSifraPrijenos"];
			c.DugIliPot = (System.Boolean)reader["DugIliPot"];
			c.Kontrola = reader.IsDBNull(reader.GetOrdinal("Kontrola")) ? null : (System.String)reader["Kontrola"];
			c.EntityTrackingKey = key;
			c.AcceptChanges();
			c.SuppressEntityEvents = false;
			}
			rows.Add(c);
		}
		return rows;
		}		
		/// <summary>
		/// Refreshes the <see cref="NetROS.Tiers.Entities.ObracunKamataProknjizen"/> object from the <see cref="IDataReader"/>.
		/// </summary>
		/// <param name="reader">The <see cref="IDataReader"/> to read from.</param>
		/// <param name="entity">The <see cref="NetROS.Tiers.Entities.ObracunKamataProknjizen"/> object to refresh.</param>
		public static void RefreshEntity(IDataReader reader, NetROS.Tiers.Entities.ObracunKamataProknjizen entity)
		{
			if (!reader.Read()) return;
			
			entity.IDKnjizenjeStavka = (System.Int32)reader["IDKnjizenjeStavka"];
			entity.OriginalIDKnjizenjeStavka = (System.Int32)reader["IDKnjizenjeStavka"];
			entity.IDOrganizacija = (System.Int32)reader["IDOrganizacija"];
			entity.IDObracunKamata = (System.Int32)reader["IDObracunKamata"];
			entity.KontoSifraPrijenos = (System.String)reader["KontoSifraPrijenos"];
			entity.DugIliPot = (System.Boolean)reader["DugIliPot"];
			entity.Kontrola = reader.IsDBNull(reader.GetOrdinal("Kontrola")) ? null : (System.String)reader["Kontrola"];
			entity.AcceptChanges();
		}
		
		/// <summary>
		/// Refreshes the <see cref="NetROS.Tiers.Entities.ObracunKamataProknjizen"/> object from the <see cref="DataSet"/>.
		/// </summary>
		/// <param name="dataSet">The <see cref="DataSet"/> to read from.</param>
		/// <param name="entity">The <see cref="NetROS.Tiers.Entities.ObracunKamataProknjizen"/> object.</param>
		public static void RefreshEntity(DataSet dataSet, NetROS.Tiers.Entities.ObracunKamataProknjizen entity)
		{
			DataRow dataRow = dataSet.Tables[0].Rows[0];
			
			entity.IDKnjizenjeStavka = (System.Int32)dataRow["IDKnjizenjeStavka"];
			entity.OriginalIDKnjizenjeStavka = (System.Int32)dataRow["IDKnjizenjeStavka"];
			entity.IDOrganizacija = (System.Int32)dataRow["IDOrganizacija"];
			entity.IDObracunKamata = (System.Int32)dataRow["IDObracunKamata"];
			entity.KontoSifraPrijenos = (System.String)dataRow["KontoSifraPrijenos"];
			entity.DugIliPot = (System.Boolean)dataRow["DugIliPot"];
			entity.Kontrola = Convert.IsDBNull(dataRow["Kontrola"]) ? null : (System.String)dataRow["Kontrola"];
			entity.AcceptChanges();
		}
		#endregion 
		
		#region DeepLoad Methods
		/// <summary>
		/// Deep Loads the <see cref="IEntity"/> object with criteria based of the child 
		/// property collections only N Levels Deep based on the <see cref="DeepLoadType"/>.
		/// </summary>
		/// <remarks>
		/// Use this method with caution as it is possible to DeepLoad with Recursion and traverse an entire object graph.
		/// </remarks>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">The <see cref="NetROS.Tiers.Entities.ObracunKamataProknjizen"/> object to load.</param>
		/// <param name="deep">Boolean. A flag that indicates whether to recursively save all Property Collection that are descendants of this instance. If True, saves the complete object graph below this object. If False, saves this object only. </param>
		/// <param name="deepLoadType">DeepLoadType Enumeration to Include/Exclude object property collections from Load.</param>
		/// <param name="childTypes">NetROS.Tiers.Entities.ObracunKamataProknjizen Property Collection Type Array To Include or Exclude from Load</param>
		/// <param name="innerList">A collection of child types for easy access.</param>
	    /// <exception cref="ArgumentNullException">entity or childTypes is null.</exception>
	    /// <exception cref="ArgumentException">deepLoadType has invalid value.</exception>
		internal override void DeepLoad(TransactionManager transactionManager, NetROS.Tiers.Entities.ObracunKamataProknjizen entity, bool deep, DeepLoadType deepLoadType, System.Type[] childTypes, DeepSession innerList)
		{
			if(entity == null)
				return;

			#region IDKnjizenjeStavkaSource	
			if (CanDeepLoad(entity, "KnjizenjeStavka|IDKnjizenjeStavkaSource", deepLoadType, innerList) 
				&& entity.IDKnjizenjeStavkaSource == null)
			{
				object[] pkItems = new object[1];
				pkItems[0] = entity.IDKnjizenjeStavka;
				KnjizenjeStavka tmpEntity = EntityManager.LocateEntity<KnjizenjeStavka>(EntityLocator.ConstructKeyFromPkItems(typeof(KnjizenjeStavka), pkItems), DataRepository.Provider.EnableEntityTracking);
				if (tmpEntity != null)
					entity.IDKnjizenjeStavkaSource = tmpEntity;
				else
					entity.IDKnjizenjeStavkaSource = DataRepository.KnjizenjeStavkaProvider.GetByID(transactionManager, entity.IDKnjizenjeStavka);		
				
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'IDKnjizenjeStavkaSource' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.IDKnjizenjeStavkaSource != null)
				{
					innerList.SkipChildren = true;
					DataRepository.KnjizenjeStavkaProvider.DeepLoad(transactionManager, entity.IDKnjizenjeStavkaSource, deep, deepLoadType, childTypes, innerList);
					innerList.SkipChildren = false;
				}
					
			}
			#endregion IDKnjizenjeStavkaSource

			#region IDObracunKamataSource	
			if (CanDeepLoad(entity, "ObracunKamata|IDObracunKamataSource", deepLoadType, innerList) 
				&& entity.IDObracunKamataSource == null)
			{
				object[] pkItems = new object[1];
				pkItems[0] = entity.IDObracunKamata;
				ObracunKamata tmpEntity = EntityManager.LocateEntity<ObracunKamata>(EntityLocator.ConstructKeyFromPkItems(typeof(ObracunKamata), pkItems), DataRepository.Provider.EnableEntityTracking);
				if (tmpEntity != null)
					entity.IDObracunKamataSource = tmpEntity;
				else
					entity.IDObracunKamataSource = DataRepository.ObracunKamataProvider.GetByID(transactionManager, entity.IDObracunKamata);		
				
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'IDObracunKamataSource' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.IDObracunKamataSource != null)
				{
					innerList.SkipChildren = true;
					DataRepository.ObracunKamataProvider.DeepLoad(transactionManager, entity.IDObracunKamataSource, deep, deepLoadType, childTypes, innerList);
					innerList.SkipChildren = false;
				}
					
			}
			#endregion IDObracunKamataSource

			#region IDOrganizacijaSource	
			if (CanDeepLoad(entity, "Organizacija|IDOrganizacijaSource", deepLoadType, innerList) 
				&& entity.IDOrganizacijaSource == null)
			{
				object[] pkItems = new object[1];
				pkItems[0] = entity.IDOrganizacija;
				Organizacija tmpEntity = EntityManager.LocateEntity<Organizacija>(EntityLocator.ConstructKeyFromPkItems(typeof(Organizacija), pkItems), DataRepository.Provider.EnableEntityTracking);
				if (tmpEntity != null)
					entity.IDOrganizacijaSource = tmpEntity;
				else
					entity.IDOrganizacijaSource = DataRepository.OrganizacijaProvider.GetByID(transactionManager, entity.IDOrganizacija);		
				
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'IDOrganizacijaSource' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.IDOrganizacijaSource != null)
				{
					innerList.SkipChildren = true;
					DataRepository.OrganizacijaProvider.DeepLoad(transactionManager, entity.IDOrganizacijaSource, deep, deepLoadType, childTypes, innerList);
					innerList.SkipChildren = false;
				}
					
			}
			#endregion IDOrganizacijaSource
			
			//used to hold DeepLoad method delegates and fire after all the local children have been loaded.
			Dictionary<string, KeyValuePair<Delegate, object>> deepHandles = new Dictionary<string, KeyValuePair<Delegate, object>>();
			
			//Fire all DeepLoad Items
			foreach(KeyValuePair<Delegate, object> pair in deepHandles.Values)
		    {
                pair.Key.DynamicInvoke((object[])pair.Value);
		    }
			deepHandles = null;
		}
		
		#endregion 
		
		#region DeepSave Methods

		/// <summary>
		/// Deep Save the entire object graph of the NetROS.Tiers.Entities.ObracunKamataProknjizen object with criteria based of the child 
		/// Type property array and DeepSaveType.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="entity">NetROS.Tiers.Entities.ObracunKamataProknjizen instance</param>
		/// <param name="deepSaveType">DeepSaveType Enumeration to Include/Exclude object property collections from Save.</param>
		/// <param name="childTypes">NetROS.Tiers.Entities.ObracunKamataProknjizen Property Collection Type Array To Include or Exclude from Save</param>
		/// <param name="innerList">A Hashtable of child types for easy access.</param>
		internal override bool DeepSave(TransactionManager transactionManager, NetROS.Tiers.Entities.ObracunKamataProknjizen entity, DeepSaveType deepSaveType, System.Type[] childTypes, DeepSession innerList)
		{	
			if (entity == null)
				return false;
							
			#region Composite Parent Properties
			//Save Source Composite Properties, however, don't call deep save on them.  
			//So they only get saved a single level deep.
			
			#region IDKnjizenjeStavkaSource
			if (CanDeepSave(entity, "KnjizenjeStavka|IDKnjizenjeStavkaSource", deepSaveType, innerList) 
				&& entity.IDKnjizenjeStavkaSource != null)
			{
				DataRepository.KnjizenjeStavkaProvider.Save(transactionManager, entity.IDKnjizenjeStavkaSource);
				entity.IDKnjizenjeStavka = entity.IDKnjizenjeStavkaSource.ID;
			}
			#endregion 
			
			#region IDObracunKamataSource
			if (CanDeepSave(entity, "ObracunKamata|IDObracunKamataSource", deepSaveType, innerList) 
				&& entity.IDObracunKamataSource != null)
			{
				DataRepository.ObracunKamataProvider.Save(transactionManager, entity.IDObracunKamataSource);
				entity.IDObracunKamata = entity.IDObracunKamataSource.ID;
			}
			#endregion 
			
			#region IDOrganizacijaSource
			if (CanDeepSave(entity, "Organizacija|IDOrganizacijaSource", deepSaveType, innerList) 
				&& entity.IDOrganizacijaSource != null)
			{
				DataRepository.OrganizacijaProvider.Save(transactionManager, entity.IDOrganizacijaSource);
				entity.IDOrganizacija = entity.IDOrganizacijaSource.ID;
			}
			#endregion 
			#endregion Composite Parent Properties

			// Save Root Entity through Provider
			if (!entity.IsDeleted)
				this.Save(transactionManager, entity);
			
			//used to hold DeepSave method delegates and fire after all the local children have been saved.
			Dictionary<Delegate, object> deepHandles = new Dictionary<Delegate, object>();
			//Fire all DeepSave Items
			foreach(KeyValuePair<Delegate, object> pair in deepHandles)
		    {
                pair.Key.DynamicInvoke((object[])pair.Value);
		    }
			
			// Save Root Entity through Provider, if not already saved in delete mode
			if (entity.IsDeleted)
				this.Save(transactionManager, entity);
				

			deepHandles = null;
						
			return true;
		}
		#endregion
	} // end class
	
	#region ObracunKamataProknjizenChildEntityTypes
	
	///<summary>
	/// Enumeration used to expose the different child entity types 
	/// for child properties in <c>NetROS.Tiers.Entities.ObracunKamataProknjizen</c>
	///</summary>
	public enum ObracunKamataProknjizenChildEntityTypes
	{
		
		///<summary>
		/// Composite Property for <c>KnjizenjeStavka</c> at IDKnjizenjeStavkaSource
		///</summary>
		[ChildEntityType(typeof(KnjizenjeStavka))]
		KnjizenjeStavka,
			
		///<summary>
		/// Composite Property for <c>ObracunKamata</c> at IDObracunKamataSource
		///</summary>
		[ChildEntityType(typeof(ObracunKamata))]
		ObracunKamata,
			
		///<summary>
		/// Composite Property for <c>Organizacija</c> at IDOrganizacijaSource
		///</summary>
		[ChildEntityType(typeof(Organizacija))]
		Organizacija,
		}
	
	#endregion ObracunKamataProknjizenChildEntityTypes
	
	#region ObracunKamataProknjizenFilterBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="SqlFilterBuilder&lt;ObracunKamataProknjizenColumn&gt;"/> class
	/// that is used exclusively with a <see cref="ObracunKamataProknjizen"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class ObracunKamataProknjizenFilterBuilder : SqlFilterBuilder<ObracunKamataProknjizenColumn>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the ObracunKamataProknjizenFilterBuilder class.
		/// </summary>
		public ObracunKamataProknjizenFilterBuilder() : base() { }

		/// <summary>
		/// Initializes a new instance of the ObracunKamataProknjizenFilterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		public ObracunKamataProknjizenFilterBuilder(bool ignoreCase) : base(ignoreCase) { }

		/// <summary>
		/// Initializes a new instance of the ObracunKamataProknjizenFilterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		/// <param name="useAnd">Specifies whether to combine statements using AND or OR.</param>
		public ObracunKamataProknjizenFilterBuilder(bool ignoreCase, bool useAnd) : base(ignoreCase, useAnd) { }

		#endregion Constructors
	}

	#endregion ObracunKamataProknjizenFilterBuilder
	
	#region ObracunKamataProknjizenParameterBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="ParameterizedSqlFilterBuilder&lt;ObracunKamataProknjizenColumn&gt;"/> class
	/// that is used exclusively with a <see cref="ObracunKamataProknjizen"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class ObracunKamataProknjizenParameterBuilder : ParameterizedSqlFilterBuilder<ObracunKamataProknjizenColumn>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the ObracunKamataProknjizenParameterBuilder class.
		/// </summary>
		public ObracunKamataProknjizenParameterBuilder() : base() { }

		/// <summary>
		/// Initializes a new instance of the ObracunKamataProknjizenParameterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		public ObracunKamataProknjizenParameterBuilder(bool ignoreCase) : base(ignoreCase) { }

		/// <summary>
		/// Initializes a new instance of the ObracunKamataProknjizenParameterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		/// <param name="useAnd">Specifies whether to combine statements using AND or OR.</param>
		public ObracunKamataProknjizenParameterBuilder(bool ignoreCase, bool useAnd) : base(ignoreCase, useAnd) { }

		#endregion Constructors
	}

	#endregion ObracunKamataProknjizenParameterBuilder
} // end namespace
